﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using FasterWPF;
using System.Windows;

namespace WPFContribDataAccess
{
    public class DataAccessFactory
    {
        private ISimpleDataAccess _sqliteDataAccess = null;
        public ISimpleDataAccess DataAccess
        {
            get { return _sqliteDataAccess; }
            set { _sqliteDataAccess = value; }
        }

        private SQLParms _sqlParms = null;

        public SQLParms SQLParms
        {
            get { return _sqlParms; }
            set { _sqlParms = value; }
        }

        public DataAccessFactory(string connectionString, WPFContribDataAccess.SQLParms.DataAccessType dataAccessType) 
        {
            _sqlParms = new SQLParms();
            _sqlParms.SQLConnectionString = connectionString;
            _sqlParms.SQLDataAccessType = dataAccessType;
            _sqliteDataAccess = GetDataAccess(dataAccessType);
            _sqliteDataAccess.SetConnection();
        }

        public ISimpleDataAccess GetDataAccess(WPFContribDataAccess.SQLParms.DataAccessType dataAccessType)
        {
            ISimpleDataAccess retVal = null;
            switch (dataAccessType)
            {
                case SQLParms.DataAccessType.OleDB:
                    retVal = new OleDBDataAccess(_sqlParms);
                    break;
                case SQLParms.DataAccessType.SQLite:
                    retVal = new SQLiteDataAccess(_sqlParms);
                    break;
                case SQLParms.DataAccessType.SQLServer:
                    break;
                case SQLParms.DataAccessType.Oracle:
                    break;
                case SQLParms.DataAccessType.mySQL:
                    break;
                case SQLParms.DataAccessType.postgreSQL:
                    break;
                case SQLParms.DataAccessType.mongoDB:
                    break;
                case SQLParms.DataAccessType.ravenDB:
                    break;
                default:
                    break;
            }

            return retVal;
        }
    }
}
